<?php

/**
 * @var $this yii\web\View
 * @var $huoke app\models\Huoke
 */

use yii\helpers\Url;
use app\helpers\Utility;


$message = Yii::$app->session->getFlash('message',null, true);

$this->title = '获客数据管理';

?>
<?php if($message):?>
    <div class="alert alert-info" role="alert"><button type="button" class="close" data-dismiss="alert" aria-label="关闭"><span aria-hidden="true">&times;</span></button><?php echo $message;?></div>
<?php endif;?>
<form id="table-form">
<table class="table table-bordered table-striped table-hover">
    <tr>
        <th class="check-all">全选</th>
        <th>导入时间</th>
        <th>推送状态</th>
        <th>页面类型</th>
        <th>是否直通</th>
        <th>数据来源</th>
        <th>城市名称</th>
        <th>姓名</th>
        <th>性别</th>
        <th>手机号</th>
        <th>税后月收入</th>
<!--        <th>Email</th>-->
        <th>媒体来源投放代码</th>
        <th>创建时间</th>
        <th>活动名称</th>
        <th>活动代码</th>
<!--        <th>拥有信用卡年限</th>-->
<!--        <th>信用卡额度</th>-->
<!--        <th>是否有信用卡</th>-->
<!--        <th>是否有贷款经历</th>-->
<!--        <th>是否有房贷</th>-->
<!--        <th>是否有车贷</th>-->
<!--        <th>是否接收优惠信息</th>-->
<!--        <th>推荐人账号</th>-->
<!--        <th>推荐人姓名</th>-->
<!--        <th>推荐人手机</th>-->
<!--        <th>学历</th>-->
<!--        <th>出生日期</th>-->
<!--        <th>名单创建来源</th>-->
<!--        <th>职业类型</th>-->
<!--        <th>发薪方式</th>-->
        <th></th>
    </tr>
    <?php foreach($huokes as $huoke):?>
        <?php
        $more = '';
        $more .= "Email：".$huoke->email."</br>";
        $more .= "拥有信用卡年限：".$huoke->creditYears."</br>";
        $more .= "信用卡额度：".$huoke->credit."</br>";
        $more .= "是否有信用卡：".$huoke->hasCreditCard."</br>";
        $more .= "是否有贷款经历：".$huoke->loanExperience."</br>";
        $more .= "是否有房贷：".$huoke->mortgage."</br>";
        $more .= "是否有车贷：".$huoke->hasCarLoan."</br>";
        $more .= "是否接收优惠信息：".$huoke->smsAccept."</br>";
        $more .= "推荐人账号：".$huoke->recommenderAccount."</br>";
        $more .= "推荐人姓名：".$huoke->recommenderName."</br>";
        $more .= "推荐人手机：".$huoke->recommenderMobile."</br>";
        $more .= "学历：".$huoke->education."</br>";
        $more .= "出生日期：".$huoke->birthDate."</br>";
        $more .= "名单创建来源：".$huoke->createSrc."</br>";
        $more .= "职业类型：".$huoke->profession."</br>";
        $more .= "发薪方式：".$huoke->payoffType."</br>";
        ?>
    <tr class="item item-<?php echo $huoke->id?>" id="item-<?php echo $huoke->id;?>" data-id="item-<?php echo $huoke->id;?>" data-tip="<?php echo $more;?>">
        <td class="skip"><input type="checkbox" class="ids" name="ids[]" id="id_<?php echo $huoke->id;?>" value="<?php echo $huoke->id;?>"/><label for="id_<?php echo $huoke->id;?>"><?php echo $huoke->id;?></label></td>
        <td><?php echo Utility::formatDate($huoke->importDate,"Y年m月d日");?></td>
        <td><?php echo $huoke->status;?></td>
        <td><?php echo $huoke->pageType;?></td>
        <td><?php echo $huoke->isDirectForm;?></td>
        <td><?php echo $huoke->custSrc;?></td>
        <td><?php echo $huoke->city;?></td>
        <td><?php echo $huoke->name;?></td>
        <td><?php echo $huoke->sex;?></td>
        <td><?php echo $huoke->teleNum;?></td>
        <td><?php echo $huoke->income;?></td>
<!--        <td>--><?php //echo $huoke->email;?><!--</td>-->
        <td><?php echo $huoke->mediaSourceId;?></td>
        <td><?php echo $huoke->applyDate;?></td>
        <td><?php echo $huoke->campaignCode;?></td>
        <td><?php echo $huoke->campaignName;?></td>
        <td class="tip">更多...</td>
    </tr>
    <?php endforeach;?>
</table>
</form>
<div class="center-block">
    <button class="btn btn-default approved-btn" type="submit">审核通过</button>
</div>
<div class="center-block">
    <?php echo $pagination;?>
</div>
<script>
    $(document).ready(function(){
        $(".item td.tip").click(function(){
            var parent = $(this).parent();
            layer.tips($(parent).data('tip'), this, {
                tips: [1, '#3595CC'],
                time: 4000
            });
        });

        $("th.check-all").click(function(){
            if($(this).hasClass('checked'))
            {
                $('.ids').attr('checked', false);
                $(this).removeClass('checked');
            }
            else
            {
                $('.ids').attr('checked', true);
                $(this).addClass('checked');
            }
        })

        $(".approved-btn").click(function(){
            var data = $("#table-form").serialize();
            $.post("<?php echo Url::toRoute('site/approve');?>",data,function(rs){
                console.log(rs);
                layer.msg("审核成功！");
            })
        });
    });
</script>

